<?php
/**
 * Created by PhpStorm.
 * User: robot
 * Date: 2018-04-16
 * Time: 22:53
 */

namespace app\base;


use app\base\model\Artcomment;
use app\base\model\Article;
use app\base\model\Classify;
use app\base\model\Sort;
use think\Controller;
use think\Session;

class BaseController extends Controller
{
    /***
     * 初始化操作
     */
    protected function _initialize()
    {
        parent::_initialize();
            if (!Auth::isLogin()) {
                if ($this->request->module() === 'admin') {
                    $this->error('请登录', '/pub/login',['referurl'=>$this->request->url()]);
                }
                $this->assign('islog', '0');
            }else{
                if ($this->request->module() === 'admin'&&Session::get('user')['user_type'] != '1') {
                    $this->error('无权访问', '/',['referurl'=>$this->request->url()]);
                }
            $this->assign('nick', Session::get('user')['user_nick']);
            $this->assign('stat', Session::get('user')['user_type']);
            $this->assign('user_img', Session::get('user')['user_img']);
            $this->assign('islog', '1');
                $this->assign('books_classify', Classify::all());



            }
    }

}